

import bpy
#import pdb

import 全局控制.Node.插座.bl_插座基类 as 插座基类
import engine.initLIB.load_dll as engineLib
import ctypes

from 节点.Core import bl_UI配色





class C_NodeSocket_节点(插座基类.C_NodeSocket_基类):
	bl_label = '节点'
	bl_icon = 'POTATO'
	
	
	#m_Value = []
	def __init__(self):
		super(C_NodeSocket_节点, self).__init__()
		self.f_setType('s_Node')

	def draw(self, context, layout, node, text):
	#def draw(self, context, layout):
		column = layout.column()
		#column.label(text=text + ':' + str(len(self.m_Value)) )
		
	def update(self):
		print('update node Object')



g_引用数据 = {}
















'''def f_socketF32Update(self, context):
	engineLib.flexCAPI.f_bl_插座传入数据(
		ctypes.c_wchar_p(self.node.id_data.name), 
		ctypes.c_wchar_p(self.node.name), 
		ctypes.c_wchar_p(self.identifier), 
		ctypes.py_object(float(self.m_Value)),
		ctypes.c_bool(self.is_output)
	)'''




class C_Socket_引用(插座基类.C_Socket_基类):
	bl_label = '引用'
	
	def __init__(self):
		super(C_Socket_引用, self).__init__()
		
	def draw(self, context, layout, node, text):
		layout.label(text=text + ' &')
	def draw_color(self, context, node):
		return bl_UI配色.g_引用插座颜色

	def update(self):
		print('update node Object')

	def f_getData(self, key=-1):
		if self.is_linked == False :
			return None
		return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		
	def f_setData(self, data):
		pass












class C_Socket_转接插座(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_转接插座, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+':&')
	def draw_color(self, context, node):
		return (1.0, 1.0, 1.0, 1.0)
		














class C_Socket_Any转PyObject(插座基类.C_Socket_基类):
	def __init__(self):
		super(C_Socket_Any转PyObject, self).__init__()

	def draw(self, context, layout, node, text):
		layout.label(text=text+'[PyObject]', icon='FILE_SCRIPT')
	def draw_color(self, context, node):
		return (0.0, 0.0, 0.0, 1.0)
		
	def f_getData(self):
		if self.is_linked:
			return engineLib.flexCAPI.f_取插座数据(ctypes.c_wchar_p(self.node.id_data.name), ctypes.c_wchar_p(self.node.name), ctypes.c_wchar_p(self.identifier))
		else:
			return []
		
	def f_setData(self):
		return None

	def f_str(self):
		return list(f_getData())









classes = (
	C_NodeSocket_节点,


	C_Socket_引用,
	C_Socket_转接插座,
	C_Socket_Any转PyObject,
)

def register():
	for c in classes:
		bpy.utils.register_class(c)
	pass	

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)
	pass
	

